﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XChipTool.Enties;

namespace XChip_Common
{
    public class SettingList_Help
    {
        /// <summary>
        /// 全局是否开启EEPROW值  默认值位false  
        /// </summary>
        public static bool isEepRom = false;
        /// <summary>
        /// 芯片为true  fpj为false
        /// </summary>
        public static bool isXChip = true;

        /// <summary>
        /// 全局数据
        /// </summary>
        private static List<xc151> xcBaseList;

        private static List<SettingTips> setTips;
        private static List<SettingTips> setTips128;
        private static List<SettingTips> setTips16;
        /// <summary>
        /// 全局数据
        /// 
        /// </summary>
        public static List<xc151> XcBaseList
        {
            get { return SettingList_Help.xcBaseList; }
            set { SettingList_Help.xcBaseList = value; }
        }
        ///// <summary>
        ///// 全局提示信息
        ///// </summary>
        //private static List<SettingTips> setTips;

        ///// <summary>
        ///// 全局数据
        ///// </summary>
        //private static List<xcindextable> xcIndexList;

        //public static List<xcindextable> XcIndexList
        //{
        //    get { return SettingList_Help.xcIndexList; }
        //    set { SettingList_Help.xcIndexList = value; }
        //}
        ///// <summary>
        ///// 用来记录操作的osd 和 setting 的类   在生成bin之前这个类都不会被初始化  在生成完bin 之后会被初始化 
        ///// </summary>
        //private static SettingDispose settingBaseList;

        //public static SettingDispose SettingBaseList
        //{
        //    get
        //    {
        //        if (null == SettingList_Help.settingBaseList)
        //        {
        //            SettingList_Help.settingBaseList = new SettingDispose();
        //        }
        //        return SettingList_Help.settingBaseList;
        //    }
        //    set { SettingList_Help.settingBaseList = value; }
        //}

        public static List<SettingTips> SetTips
        {
            get
            {
                if (null == setTips)
                {
                    setTips = new List<SettingTips>();
                }
                return setTips;
            }

            set
            {
                setTips = value;
            }
        }

        public static void ClearSetTips32() {
            setTips128 = null;
        }

        public static List<SettingTips> SetTips128
        {
            get
            {
                if (null == setTips128)
                {
                    setTips128 = new List<SettingTips>();
                    for (int i = 0; i < 128; i++)
                    {
                        setTips128.Add(new SettingTips());
                    }
                }
                return setTips128;
            }

            set
            {
                setTips128 = value;
            }
        }


        public static List<SettingTips> SetTips16 {
            get
            {
                if (null == setTips16)
                {
                    setTips16 = new List<SettingTips>();
                    for (int i = 0; i < 16; i++)
                    {
                        setTips16.Add(new SettingTips());
                    }
                }
                return setTips16;
            }

            set
            {
                setTips16 = value;
            }
        }

        public static void SetTipsNew16() {
            setTips16 = new List<SettingTips>();
            for (int i = 0; i < 16; i++)
            {
                setTips16.Add(new SettingTips());
            }
        }
        public static List<T> PraseList<T>(object listObj)
        {
            List<T> result = new List<T>();
            if (!listObj.GetType().IsGenericType)
                throw new Exception("非集合类型");
            if (listObj as System.Collections.ICollection != null)
            {
                var list = (System.Collections.ICollection)listObj;
                if (list.Count > 0)
                {
                    foreach (var item in list)
                    {
                        result.Add((T)item);
                    }
                }
            }
            return result;
        }

        //将字符串模式的byte数组转换为实际意义的byte数组
        public static byte[] HexStringToByteArray(string str)
        {
            str = str.Replace(" ", "");//先替换其中的空格等
            byte[] buffer = new byte[str.Length / 2];//新建一个byte数组用来保存，长度是字符串长度的一半
            for (int i = 0; i < str.Length; i += 2)//循环遍历字符串来赋值给byte数组
                buffer[i / 2] = (byte)Convert.ToByte(str.Substring(i, 2), 16);//按2位来截取转换为byte数据
            return buffer;//返回转换之后的byte数组
        }

        public static List<string> HexStringToStringList(string str)
        {
            List<string> strlist = new List<string>();
            var str8 = str.PadLeft(8, '0');
            for (int i = 0; i < str8.Length; i += 2)
            {
                strlist.Add(str8.Substring(i, 2));
            }
            return strlist;
        }


        public static void setDataexample(string address, bool Checked)
        {
            if (null != SettingList_Help.XcBaseList)
            {
                SettingList_Help.XcBaseList.ForEach(c =>
                {
                    if (c.address == address)
                    {
                        c.dataexample = Checked ? c.dataexample : "0x00";
                        return;
                    }
                });
            }
        }

        ///// <summary>
        ///// Setting0_0 清空配置
        ///// </summary>
        //public static void Setting0_0Cleaning()
        //{

        //    //setDataexample("0x0014", false);
        //    //setDataexample("0x0015", false);
        //    //setDataexample("0x0016", false);
        //    //setDataexample("0x0017", false);
        //    //setDataexample("0x0018", false);
        //    //setDataexample("0x0019", false);
        //    //setDataexample("0x001A", false);
        //    //setDataexample("0x001B", false);
        //    //setDataexample("0x001C", false);
        //    //setDataexample("0x001D", false);
        //    //setDataexample("0x001E", false);
        //    //setDataexample("0x001F", false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 24).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 24).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 24).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 24).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 25).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 25).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 25).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 25).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 26).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 26).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 26).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 26).ToList()[3].address, false);
        //    if (null != SettingBaseList.Setting0_0)
        //    {
        //        SettingBaseList.Setting0_0.isAddress = false;
        //    }

        //}
        ///// <summary>
        ///// Setting0_1 清空配置
        ///// </summary>
        //public static void Setting0_1Cleaning()
        //{
        //    //setDataexample("0x0024", false);
        //    //setDataexample("0x0025", false);
        //    //setDataexample("0x0026", false);
        //    //setDataexample("0x0027", false);
        //    //setDataexample("0x0028", false);
        //    //setDataexample("0x0029", false);
        //    //setDataexample("0x002A", false);
        //    //setDataexample("0x002B", false);
        //    //setDataexample("0x002C", false);
        //    //setDataexample("0x002D", false);
        //    //setDataexample("0x002E", false);
        //    //setDataexample("0x002F", false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 28).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 28).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 28).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 28).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 29).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 29).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 29).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 29).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 30).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 30).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 30).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 30).ToList()[3].address, false);
        //    if (null != SettingBaseList.Setting0_1)
        //    {
        //        SettingBaseList.Setting0_1.isAddress = false;
        //    }

        //}
        ///// <summary>
        ///// Setting0_2 清空配置
        ///// </summary>

        //public static void Setting0_2Cleaning()
        //{
        //    //setDataexample("0x0034", false);
        //    //setDataexample("0x0035", false);
        //    //setDataexample("0x0036", false);
        //    //setDataexample("0x0037", false);
        //    //setDataexample("0x0038", false);
        //    //setDataexample("0x0039", false);
        //    //setDataexample("0x003A", false);
        //    //setDataexample("0x003B", false);
        //    //setDataexample("0x003C", false);
        //    //setDataexample("0x003D", false);
        //    //setDataexample("0x003E", false);
        //    //setDataexample("0x003F", false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 32).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 32).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 32).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 32).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 33).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 33).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 33).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 33).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 34).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 34).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 34).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 34).ToList()[3].address, false);
        //    if (null != SettingBaseList.Setting0_2)
        //    {
        //        SettingBaseList.Setting0_2.isAddress = false;
        //    }

        //}

        ///// <summary>
        ///// Setting0_Patch 清空配置
        ///// </summary>
        //public static void Setting0_PatchCleaning()
        //{
        //    //补丁地址
        //    //setDataexample("0x0044", false);
        //    //setDataexample("0x0045", false);
        //    //setDataexample("0x0046", false);
        //    //setDataexample("0x0047", false);
        //    //长度
        //    //setDataexample("0x004C", false);
        //    //setDataexample("0x004D", false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 36).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 36).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 36).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 36).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 38).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 38).ToList()[1].address, false);
        //    if (null != SettingBaseList.Setting0_Patch)
        //    {
        //        SettingBaseList.Setting0_Patch.isAddress = false;
        //    }

        //}

        ///// <summary>
        ///// Setting1_0 清空配置
        ///// </summary>

        //public static void Setting1_0Cleaning()
        //{
        //    //setDataexample("0x0054", false);
        //    //setDataexample("0x0055", false);
        //    //setDataexample("0x0056", false);
        //    //setDataexample("0x0057", false);
        //    //setDataexample("0x0058", false);
        //    //setDataexample("0x0059", false);
        //    //setDataexample("0x005A", false);
        //    //setDataexample("0x005B", false);
        //    //setDataexample("0x005C", false);
        //    //setDataexample("0x005D", false);
        //    //setDataexample("0x005E", false);
        //    //setDataexample("0x005F", false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 41).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 41).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 41).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 41).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 42).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 42).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 42).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 42).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 43).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 43).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 43).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 43).ToList()[3].address, false);
        //    if (null != SettingBaseList.Setting1_0)
        //    {
        //        SettingBaseList.Setting1_0.isAddress = false;
        //    }

        //}

        ///// <summary>
        ///// Setting1_1 清空配置
        ///// </summary>
        //public static void Setting1_1Cleaning()
        //{

        //    //setDataexample("0x0064", false);
        //    //setDataexample("0x0065", false);
        //    //setDataexample("0x0066", false);
        //    //setDataexample("0x0067", false);
        //    //setDataexample("0x0068", false);
        //    //setDataexample("0x0069", false);
        //    //setDataexample("0x006A", false);
        //    //setDataexample("0x006B", false);
        //    //setDataexample("0x006C", false);
        //    //setDataexample("0x006D", false);
        //    //setDataexample("0x006E", false);
        //    //setDataexample("0x006F", false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 45).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 45).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 45).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 45).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 46).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 46).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 46).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 46).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 47).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 47).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 47).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 47).ToList()[3].address, false);
        //    if (null != SettingBaseList.Setting1_1)
        //    {
        //        SettingBaseList.Setting1_1.isAddress = false;
        //    }

        //}

        ///// <summary>
        ///// Setting1_2 清空配置
        ///// </summary>
        //public static void Setting1_2Cleaning()
        //{

        //    //setDataexample("0x0074", false);
        //    //setDataexample("0x0075", false);
        //    //setDataexample("0x0076", false);
        //    //setDataexample("0x0077", false);
        //    //setDataexample("0x0078", false);
        //    //setDataexample("0x0079", false);
        //    //setDataexample("0x007A", false);
        //    //setDataexample("0x007B", false);
        //    //setDataexample("0x007C", false);
        //    //setDataexample("0x007D", false);
        //    //setDataexample("0x007E", false);
        //    //setDataexample("0x007F", false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 49).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 49).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 49).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 49).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 50).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 50).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 50).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 50).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 51).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 51).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 51).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 51).ToList()[3].address, false);
        //    if (null != SettingBaseList.Setting1_2)
        //    {
        //        SettingBaseList.Setting1_2.isAddress = false;
        //    }

        //}

        ///// <summary>
        ///// Setting1_Patch 清空配置
        ///// </summary>
        //public static void Setting1_PatchCleaning()
        //{
        //    //setDataexample("0x0084", false);
        //    //setDataexample("0x0085", false);
        //    //setDataexample("0x0086", false);
        //    //setDataexample("0x0087", false);
        //    //setDataexample("0x008C", false);
        //    //setDataexample("0x008D", false);

        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 53).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 53).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 53).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 53).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 55).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 55).ToList()[1].address, false);
        //    if (null != SettingBaseList.Setting1_Patch)
        //    {
        //        SettingBaseList.Setting1_Patch.isAddress = false;
        //    }

        //}
        ///// <summary>
        ///// 清空osd
        ///// </summary>
        //public static void osd_Cleaning()
        //{
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 58).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 58).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 58).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 58).ToList()[3].address, false);


        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 59).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 59).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 59).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 59).ToList()[3].address, false);


        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 60).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 60).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 60).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 60).ToList()[3].address, false);

        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 61).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 61).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 61).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 61).ToList()[3].address, false);

        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 62).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 62).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 62).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 62).ToList()[3].address, false);

        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 63).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 63).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 63).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 63).ToList()[3].address, false);


        //    //setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 64).ToList()[0].address, false);
        //    //setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 64).ToList()[1].address, false);
        //    //setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 64).ToList()[2].address, false);
        //    //setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 64).ToList()[3].address, false);


        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 65).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 65).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 65).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 65).ToList()[3].address, false);


        //    //setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 66).ToList()[0].address, false);
        //    //setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 66).ToList()[1].address, false);
        //    //setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 66).ToList()[2].address, false);
        //    //setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 66).ToList()[3].address, false);

        //    if (null != SettingBaseList.osdcheck)
        //    {
        //        settingBaseList.osdcheck.Clear();
        //    }
        //}
        ///// <summary>
        ///// Spare_0 清空配置
        ///// </summary>
        //public static void Spare_0Cleaning()
        //{
        //    //setDataexample("0x00C4", false);
        //    //setDataexample("0x00C5", false);
        //    //setDataexample("0x00C6", false);
        //    //setDataexample("0x00C7", false);
        //    //setDataexample("0x00C8", false);
        //    //setDataexample("0x00C9", false);
        //    //setDataexample("0x00CA", false);
        //    //setDataexample("0x00CB", false);
        //    //setDataexample("0x00CC", false);
        //    //setDataexample("0x00CD", false);
        //    //setDataexample("0x00CE", false);
        //    //setDataexample("0x00CF", false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 68).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 68).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 68).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 68).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 69).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 69).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 69).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 69).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 70).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 70).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 70).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 70).ToList()[3].address, false);
        //    if (null != SettingBaseList.Spare_0)
        //    {
        //        SettingBaseList.Spare_0.isAddress = false;
        //    }
        //}
        ///// <summary>
        ///// Spare_1 清空配置
        ///// </summary>
        //public static void Spare_1Cleaning()
        //{
        //    //setDataexample("0x00D4", false);
        //    //setDataexample("0x00D5", false);
        //    //setDataexample("0x00D6", false);
        //    //setDataexample("0x00D7", false);
        //    //setDataexample("0x00D8", false);
        //    //setDataexample("0x00D9", false);
        //    //setDataexample("0x00DA", false);
        //    //setDataexample("0x00DB", false);
        //    //setDataexample("0x00DC", false);
        //    //setDataexample("0x00DD", false);
        //    //setDataexample("0x00DE", false);
        //    //setDataexample("0x00DF", false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 72).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 72).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 72).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 72).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 73).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 73).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 73).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 73).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 74).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 74).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 74).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 74).ToList()[3].address, false);
        //    if (null != SettingBaseList.Spare_1)
        //    {
        //        SettingBaseList.Spare_1.isAddress = false;
        //    }
        //}
        ///// <summary>
        ///// Spare_2 清空配置
        ///// </summary>
        //public static void Spare_2Cleaning()
        //{
        //    //setDataexample("0x00E4", false);
        //    //setDataexample("0x00E5", false);
        //    //setDataexample("0x00E6", false);
        //    //setDataexample("0x00E7", false);
        //    //setDataexample("0x00E8", false);
        //    //setDataexample("0x00E9", false);
        //    //setDataexample("0x00EA", false);
        //    //setDataexample("0x00EB", false);
        //    //setDataexample("0x00EC", false);
        //    //setDataexample("0x00ED", false);
        //    //setDataexample("0x00EE", false);
        //    //setDataexample("0x00EF", false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 76).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 76).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 76).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 76).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 77).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 77).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 77).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 77).ToList()[3].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 78).ToList()[0].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 78).ToList()[1].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 78).ToList()[2].address, false);
        //    setDataexample(SettingList_Help.XcBaseList.Where(c => c.xcindexId == 78).ToList()[3].address, false);
        //    if (null != SettingBaseList.Spare_2)
        //    {
        //        SettingBaseList.Spare_2.isAddress = false;
        //    }
        //}

        /// <summary>
        /// 
        /// </summary>
        /// <param name="address">首地址</param>
        /// <param name="lengthAddress">长度</param>
        /// <param name="cycleNumber">套数</param>
        /// <param name="isbool">是否计算套数</param>
        /// <returns></returns>
        public static string NextEnableAddress(string address, string lengthAddress, string cycleNumber, bool isbool)
        {
            if (isbool)
            {
                var shouu = Convert.ToUInt32(address, 16);
                var lengthu1 = Convert.ToUInt32(lengthAddress, 16);
                uint lengthu;
                if (SettingList_Help.isEepRom)
                {
                    lengthu = Convert.ToUInt32(lengthAddress, 16);
                    var cycleu = int.Parse(cycleNumber);
                    var newshou = (shouu + 0x0008 + (cycleu * lengthu)).ToString("X4");
                    return newshou;
                }
                else
                {
                    #region 补齐长度
                    var lengNumYu = Convert.ToUInt32(lengthAddress, 16) / 0x1000;
                    var lengNumMo = Convert.ToUInt32(lengthAddress, 16) % 0x1000;
                    if (lengNumMo > 0)
                    {
                        lengNumYu += 1;
                    }
                    lengthu = lengNumYu * 0x1000;
                    #endregion
                    var cycleu = int.Parse(cycleNumber);
                    var newshou = (shouu + 0x1000 + (cycleu * lengthu)).ToString("X4");
                    return newshou;
                }


                //补齐长度  
                //var lengthu =Convert.ToUInt32((Math.Ceiling(Convert.ToInt32(lengthAddress,16)/4096.0) *1000).ToString(),16);

            }
            else
            {
                var shouu = Convert.ToUInt32(address, 16);
                //var lengthu = Convert.ToUInt32(lengthAddress, 16);
                //补齐长度
                //var lengthu = Convert.ToUInt32((Math.Ceiling(Convert.ToInt32(lengthAddress,16) / 4096.0) * 1000).ToString(), 16);
                uint lengthu;
                if (SettingList_Help.isEepRom)
                {
                    lengthu = Convert.ToUInt32(lengthAddress, 16);

                }
                else
                {
                    #region 补齐长度
                    var lengNumYu = Convert.ToUInt32(lengthAddress, 16) / 0x1000;
                    var lengNumMo = Convert.ToUInt32(lengthAddress, 16) % 0x1000;
                    if (lengNumMo > 0)
                    {
                        lengNumYu += 1;
                    }
                    lengthu = lengNumYu * 0x1000;
                    #endregion

                }

                var newshou = (shouu + lengthu).ToString("X4");
                return newshou;
            }
        }


        #region OSD赋值
        //public static void OsdSetAddress(string tempOne)
        //{

        //    tempOne = (Convert.ToUInt32(tempOne, 16) - 0x1000).ToString("X4");
        //    List<string> listNumber = SettingList_Help.HexStringToStringList(tempOne);
        //    SetXcList(listNumber, 58);

        //    //   OSD当前数据（2）
        //    var tempTwo = (Convert.ToUInt32(tempOne, 16) + 0x1000).ToString("X4");
        //    listNumber = SettingList_Help.HexStringToStringList(tempTwo);
        //    SetXcList(listNumber, 59);

        //    //   OSD当前数据（3）
        //    var tempThree = (Convert.ToUInt32(tempTwo, 16) + 0x1000).ToString("X4");
        //    listNumber = SettingList_Help.HexStringToStringList(tempThree);
        //    SetXcList(listNumber, 60);

        //    //   OSD出厂数据
        //    var tempFour = (Convert.ToUInt32(tempThree, 16) + 0x1000).ToString("X4");
        //    listNumber = SettingList_Help.HexStringToStringList(tempFour);
        //    SetXcList(listNumber, 61);

        //    //   OSD当前使用的语言的编号的地址
        //    var tempFive = (Convert.ToUInt32(tempFour, 16) + 0x1000).ToString("X4");
        //    listNumber = SettingList_Help.HexStringToStringList(tempFive);
        //    SetXcList(listNumber, 62);

        //    uint language_caidan = 0x3000;
        //    //uint language_ziku = 0x9000;
        //    var tempSix = (Convert.ToUInt32(tempFive, 16) + 0x1000).ToString("X4");
        //    listNumber = SettingList_Help.HexStringToStringList(tempSix);
        //    SetXcList(listNumber, 63);
        //    //var languageNum = Convert.ToUInt32(SettingList_Help.SettingBaseList.osdcheck.Where(c => c.menu_osd.isAddress == true).First().cycleNumber);
        //    //var tempSeven = (Convert.ToUInt32(tempSix, 16) + (language_caidan * (languageNum))).ToString("X4");
        //    listNumber = SettingList_Help.HexStringToStringList(tempSeven);
        //    SetXcList(listNumber, 65);

        //}
        /// <summary>
        /// list分解值 Osd设置值
        /// </summary>
        /// <param name="listNumber"></param>
        /// <param name="id"></param>
        static void SetXcList(List<string> listNumber, int id)
        {

            switch (listNumber.Count)
            {
                case 1:
                    break;
                case 2:
                    break;
                case 3:
                    break;
                case 4:
                    SetXcBase(SettingList_Help.XcBaseList.Where(c => c.xcindexId == id).ToList()[0].address, listNumber[0]);
                    SetXcBase(SettingList_Help.XcBaseList.Where(c => c.xcindexId == id).ToList()[1].address, listNumber[1]);
                    SetXcBase(SettingList_Help.XcBaseList.Where(c => c.xcindexId == id).ToList()[2].address, listNumber[2]);
                    SetXcBase(SettingList_Help.XcBaseList.Where(c => c.xcindexId == id).ToList()[3].address, listNumber[3]);
                    break;
                default:
                    break;
            }
        }
        static void SetXcBase(string _address, string _dataexample)
        {
            SettingList_Help.XcBaseList.ForEach(c =>
            {
                if (c.address == _address)
                {
                    c.dataexample = string.Format("0x{0}", _dataexample);
                    return;
                }
            });

        }
        #endregion




    }

    
}
